package com.niit.repository;

import com.niit.entity.Application;
import com.niit.entity.Job;
import com.niit.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ApplicationRepository extends JpaRepository<Application, Integer> {
    //查询求职者的所有申请
    List<Application> findBySeeker(User seeker);

    //查询某个职位的所有申请
    List<Application> findByJob(Job job);

    //查询某个职位的申请数量
    Long countByJob(Job job);


    //查询某个发布者的所有职位申请
    @Query("SELECT a FROM Application a WHERE a.job.user =?1")
    List<Application> findByJobPoster(User user);

    boolean existsByJobIdAndSeekerId(Integer jobId, Integer seekerId);
}
